<?php
//------------------------------------------------------------------------------
// File               : V_DownloadDriverList
// Modification       :
//------------------------------------------------------------------------------
// Date(yyyy.mm.dd)   Developer                       Action
//------------------------------------------------------------------------------
// 2007.03.15         Oanhhtk                         Created
//------------------------------------------------------------------------------

function V_DownloadList(&$arrayData,$action){	
	global $LANG;
    $ulr = "?".MODUL."=download&".ACTION."=";
	global $db;
	//phan trang
	$totalRows = 0;
	$curPage =1;
	$strStart =0;
	$strEnd=0;
	
	$totalRows=count($arrayData);
	$totalRecord = 30;
	
	$curPage =CM_getParameter("curPg");
	if(((int)$curPage)==0) $curPage =1;
	
	$totalPage = 	(int)($totalRows/$totalRecord);
	if($totalRows % $totalRecord > 0 ) $totalPage ++;
	
	if($totalRows >0){
		$strStart = ($curPage -1) * $totalRecord+1;
		$strEnd   = ($curPage )   * $totalRecord ;
		if($strEnd  > $totalRows ) $strEnd  = $totalRows;
	}
	
?>
<script>
function GotoPage(iPage) 
{
    document.frm.curPg.value=iPage;
	document.frm.action = "../run/main.php?modul=download&action=<?=$action?>&curPage="+iPage;
    document.frm.submit()  ;
}
</script>
<div class="title" style="margin-left:10px; width:10px; height:30px; float:left"></div>
<p style="float:left; line-height:30px; font-weight:bold; color:#FFFFFF; background: url(../images/modul_c.gif)">Danh sách các file download</p>
<div class="title2" style="width:10px; height:30px; float:left"></div>
<div style="clear:both"></div>
<div class="bg_l_t"><div class="bg_r_t"><div class="bg_c_t"></div></div></div>
<form name="frm" action=""  method="post" >
<table width="100%" cellpadding="0" cellspacing="0" class="khung_home">
	<tr>
		<td>
			<table width="98%" cellpadding="3" cellspacing="2"  style="border-collapse:collapse; line-height:18px; border:1px solid #99CCFF;  ">
				<tr>
					<th width="8%" align="center" style="background-color:#CCCCFF; border-right:1px solid #99CCFF; border-collapse:collapse; ">Stt</th>
					<th width="76%" align="left" style="background-color:#CCCCFF; border-right:1px solid #99CCFF; border-collapse:collapse; padding-left:10px;">Nội dung file</th>
					<th width="16%" align="center" style="background-color:#CCCCFF;">Download</th>
				</tr>
				<?
				if(!empty($arrayData)){
					$curRow=0;
					$i=0;
					$stt = 0;
					foreach($arrayData as $row){
						$curRow ++;
						if( $curRow < $strStart ) continue;
						if( $curRow > $strEnd )  break;
						$i=+1;
						$stt ++;
				?>
				<tr>
					<td align="center" style="border-right:1px solid #99CCFF; border-collapse:collapse; border-bottom:1px solid #99CCFF;">
						<?=$stt?>
					</td>
					<td style="border-right:1px solid #99CCFF; border-collapse:collapse; padding-left:10px; padding-right:10px; border-bottom:1px solid #99CCFF;">
						<?=$row['tieu_de']?>
					</td>
					<td align="center" style="border-bottom:1px solid #99CCFF; border-collapse:collapse;">
						<a href="<?=DIR_DOWNLOAD_FILE_BAO_GIA.$row['ten_file']?>"><img src="../images/Download.png" border="0" style="width:25px; " title="Download"></a>
					</td>
				</tr>
				<?
					}//end foreach
				}//end if
				?>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<?
			if($totalPage>1){	
			?>
			<table  cellpadding="0" cellspacing="0" align="center">
				<br>
				<tr>
					<td class="pagingIntact">
						<a href="javascript:GotoPage('1')">&nbsp;&laquo;&nbsp;Trang đầu&nbsp;</a>
					</td>
					<td class="pagingSpace"></td>
					<?
					for($i=1;$i<= $totalPage;$i++){
						if($i < $curPage + 11 && $i > $curPage - 11){
							if($i == $curPage){
					?>
					<td class="pagingViewed">
						<?=$i?>
					</td>
					<td class="pagingSpace"></td>
					<?
							}
							if($i != $curPage){
					?>
					<td class="pagingIntact">
						<a href="javascript:GotoPage('<?=$i?>')"><?=$i?></a>
					</td>
					<td class="pagingSpace"></td>
					<?
							}
						} 
					}
					?>
					<td class="pagingIntact">
						<a href="javascript:GotoPage('<?=$totalPage?>')">&nbsp;Trang cuối&nbsp;&raquo;&nbsp;</a>
					</td>
				</tr>
			</table>
			<?
			}//end if($totalPage>1)
			?>
		</td>
	</tr>
	<tr><td style="padding:30px; ">&nbsp;</td></tr>
</table>
<input type=hidden  name="curPg"  value="0" >
<input type=hidden  name="id"  value="<?=CM_getParameter('id')?>" >
<input type=hidden  name="textfield"  value="<?=CM_getParameter('textfield')?>" >
</form>
<div class="bg_l_b"><div class="bg_r_b"><div class="bg_c_b"></div></div></div>
<?
	foreach ($_POST as $key => $value) {
		$value = htmlspecialchars( CM_getParameter($key));
		echo '<input type=hidden  name="'.$key.'"  value="'.$value.'" >';
		echo "\n";
	}
}// ket thuc ham
?>